const Redux = require('redux')
const createStore = Redux.createStore;


const reducer = (state = 'GO', action) => {
    switch (action.type) {
        case 'GO':
            state = 'GO'
            break;
        case 'STOP':
            state = 'STOP'
            break;
        case 'CAUTION':
            state = 'CAUTION'
            break;
    }
    return state;
}

const cautionAction = {
    type: 'CAUTION'
}

const goAction = {
    type: 'GO'
}

const stopAction = {
    type: 'STOP'
}

const store = createStore(reducer)


store.dispatch(stopAction)
console.log('State: ' + store.getState())       // State: STOP
store.dispatch(cautionAction)
console.log('State: ' + store.getState())       // State: CAUTION
store.dispatch(goAction)
console.log('State: ' + store.getState())       // State: GO